package com.stack.common.utils;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.UUID;

/**
 * @author llz
 * @date 2022/6/23 16:15
 * @description uuid工具类
 */
public class UuidUtil {

	private UuidUtil() {
		throw new IllegalStateException("Utility class");
	}

	public static String getUuid(){
		return UUID.randomUUID().toString().replace("-","");
	}

	public static String randomInt(int num){
		StringBuilder sb = new StringBuilder();
		for (int i=0; i<num; i++) {
			sb.append(new Random().nextInt(9));
		}
		return sb.toString();
	}

	public static int randomInt(int min, int bound) {
		try {
			return min + SecureRandom.getInstanceStrong().nextInt(bound);
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException(e);
		}
	}

}
